<?php
    
    

?>

<html>
    <head>
        
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <script src="../../../vista/php/jquery-1.9.1.min.js"></script>
        
        
        <script>
            function cargarClasif(){
                
                var tc = 4;
                $.ajax({
                    type: "POST",
                    contentType: "application/x-www-form-urlencoded; charset=UTF-8",
                    url: "../../controlador/consultas/crudClasificacion.php",
                    data:{tc:tc},
                    success: mostrarClasif,
                    timeout: 4000
                });
                
            }
            
            function mostrarClasif(datos){
                
                $("#restn").text('');
                rpt = $.parseJSON(datos);
                datos = $("#restn");
                
                var resp = "";
                var con = 1; 
                
                resp += "<table style='width:100%;font-size:70%'>\
                            <tr>\
                                <td align='center' style='background-color: whitesmoke;border-radius:5px'>\
                                </td>\
                                <td align='center' style='padding:10px;background-color: whitesmoke;border-radius:5px'>\
                                    <strong>Clasificacion</strong>\
                                </td>\
                                <td align='center' style='padding:10px;background-color: whitesmoke;border-radius:5px'>\
                                    <strong>Color</strong>\
                                </td>\
                            </tr>";
                for(r in rpt){
                    
                    var esta = rpt[r].estado;
                    
                    if(esta == 1){
                        var estado = "Activa"; 
                    }else if(esta == 2){
                        estado = "Inactiva";
                    }
                    
                    var descricam = '"'+rpt[r].descripcion+'"';
                    var color = '"'+rpt[r].color+'"';
                    
                    resp += "<tr>\
                                <td style='padding:10px 10px 10px; text-align:center;border-top:1px solid #e0e0e0; border-right:1px solid #e0e0e0;background: -moz-linear-gradient(100% 25% 90deg, #fefefe, #f9f9f9);background: -webkit-gradient(linear, 0% 0%, 0% 25%, from(#f9f9f9), to(#fefefe));'>\
                                    "+ con +"\
                                </td>\
                                <td style='padding:10px 10px 10px; text-align:center;border-top:1px solid #e0e0e0; border-right:1px solid #e0e0e0;background: -moz-linear-gradient(100% 25% 90deg, #fefefe, #f9f9f9);background: -webkit-gradient(linear, 0% 0%, 0% 25%, from(#f9f9f9), to(#fefefe));'>\
                                    "+ rpt[r].descripcion +"\
                                </td>\
                                <td align='center' style='padding:10px 10px 10px;border-top:1px solid #e0e0e0; border-right:1px solid #e0e0e0;background: -moz-linear-gradient(100% 25% 90deg, #fefefe, #f9f9f9);background: -webkit-gradient(linear, 0% 0%, 0% 25%, from(#f9f9f9), to(#fefefe));'>\
                                    <div onclick='pintar("+ color +","+ rpt[r].oid +");' align=center style='cursor:pointer;width:30px;height:30px;background-color:"+ rpt[r].color +";'></div>\
                                </td>\
                             </tr>";
                   con++;
                }
                resp += "</table>";
                datos.append(resp);
                
            }
            
            function pintar(color,oidc){
                
                var posi = document.getElementById("posi").value; 
                window.opener.insertarColor(color,posi,oidc);
                window.close();
                
            }
            
        </script>
        
    </head>
    <body onload="cargarClasif();">
        
        <div align="center" style="background-color:#e8eaeb;height:10%;width:100%;">
            <table style="width:100%; height:10%;" >
                <td align="center" width="90%">
                <div style="font-size: 75%;"><b>CLASIFICACIONES</b></div>
                </td>
            </table>

        </div>
        <div style='overflow-y: scroll;height:77%;'>
        <div id="restn">
            
        </div>
        </div>
        <div style="background-color:#e8eaeb;height:12%;width:100%;">
            <div style="padding:1%;">
            </div>
        </div>
        
    </body>
</html>
<input type="hidden" id="posi" name="" value="<?php echo$_REQUEST['pos'] ?>" />